package com.zhq.blog.core.domain.game;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.PostLoad;
import javax.persistence.Transient;

import com.zhq.blog.core.domain.BasePersistentDomain;


/**
 * @title:GamePeriod.java
 * @package com.zhq.blog.core.domain.game
 * @author 张恒强
 * @date 2014年12月27日 上午11:12:53
 * @version V1.0
 */
@Entity
public class GamePeriod extends BasePersistentDomain<GamePeriodRepository>{
	public enum GamePeriodState{
		TO_BE_LOTTERY("未开奖"),LOTTERYING("摇奖中"),LOTTERYED("已开奖");
		public String description;
		GamePeriodState(final String description){
			this.description = description;
		}
	}
	/**
	 * 前台要注意 如果后台已经人工设置了开奖结果  那么要直到开奖时间才可以显示开奖结果
	 * @author lenovo
	 *
	 */
	public enum LotteryMethod{
		MUNURAL("人工干预开奖"),AUTO("有人投注,按照算法开奖"),AUTO_RANDOM("无人投注,自动随机开奖");
		public String description;
		LotteryMethod(final String description){
			this.description = description;
		}
	}
	
	private LotteryMethod lotteryMethod = LotteryMethod.AUTO;
	
	
	//手动自动生成  区分游戏类型
	private long period;//期数
	
	private long gameId;//游戏类型ID
	
	private Date lotteryTime;
	
	//可以根据游戏的类型和开奖的数字以及生成开奖结果的数字 来找到具体的图片 在前台显示
	//  总路径/images/game/游戏类型ID/*.png
	private int resultNumber;//开奖结果
	
	private String resultFromNumbers; //生成开奖结果的数字 以逗号分隔
	
	private long totalMoney;//奖池总数
	
	private int bettingUserNumber;//押注人数
	
	private int winnerNumbers;//一开始为0 开奖后公布
	
	private GamePeriodState state = GamePeriodState.TO_BE_LOTTERY;
	
	@Transient
	private long singleUserBetMoney;//我投注了多少
	@Transient
	private long singleUserWinMoney;//我中奖了多少
	@Transient 
	private long profit;//赢利
	@Transient
	private double profitRate;//盈亏比例
	
	@Transient
	private String[] resultFromNumbers_arr;
	
	@Transient
	private boolean even;//是否是双
	@Transient
	private boolean side;//是否是边
	@Transient
	private boolean big;//是否是大
	@Transient
	private boolean big_tail;//是否是大尾
	
	public boolean isEven() {
		return even;
	}

	public void setEven(boolean even) {
		this.even = even;
	}

	public boolean isSide() {
		return side;
	}

	public void setSide(boolean side) {
		this.side = side;
	}

	public boolean isBig() {
		return big;
	}

	public void setBig(boolean big) {
		this.big = big;
	}

	public boolean isBig_tail() {
		return big_tail;
	}

	public void setBig_tail(boolean big_tail) {
		this.big_tail = big_tail;
	}

	public long getProfit() {
		return profit;
	}

	public void setProfit(long profit) {
		this.profit = profit;
	}

	public double getProfitRate() {
		return profitRate;
	}

	public void setProfitRate(double profitRate) {
		this.profitRate = profitRate;
	}

	public String[] getResultFromNumbers_arr() {
		return resultFromNumbers_arr;
	}

	public void setResultFromNumbers_arr(String[] resultFromNumbers_arr) {
		this.resultFromNumbers_arr = resultFromNumbers_arr;
	}

	@PostLoad
	public void init(){
		if (resultFromNumbers!= null) {
			resultFromNumbers_arr = resultFromNumbers.split(",");
		}
	}
	
	public LotteryMethod getLotteryMethod() {
		return lotteryMethod;
	}
	public void setLotteryMethod(LotteryMethod lotteryMethod) {
		this.lotteryMethod = lotteryMethod;
	}
	public GamePeriod(long period, long gameId, Date lotteryTime,
			long totalMoney) {
		super();
		this.period = period;
		this.gameId = gameId;
		this.lotteryTime = lotteryTime;
		this.totalMoney = totalMoney;
	}
	public GamePeriod() {
		super();
	}
	public GamePeriodState getState() {
		return state;
	}
	public void setState(GamePeriodState state) {
		this.state = state;
	}
	public long getPeriod() {
		return period;
	}
	public void setPeriod(long period) {
		this.period = period;
	}
	public long getGameId() {
		return gameId;
	}
	public void setGameId(long gameId) {
		this.gameId = gameId;
	}
	public Date getLotteryTime() {
		return lotteryTime;
	}
	public void setLotteryTime(Date lotteryTime) {
		this.lotteryTime = lotteryTime;
	}
	public int getResultNumber() {
		return resultNumber;
	}
	public void setResultNumber(int resultNumber) {
		this.resultNumber = resultNumber;
	}
	public String getResultFromNumbers() {
		return resultFromNumbers;
	}
	public void setResultFromNumbers(String resultFromNumbers) {
		this.resultFromNumbers = resultFromNumbers;
	}
	public long getTotalMoney() {
		return totalMoney;
	}
	public void setTotalMoney(long totalMoney) {
		this.totalMoney = totalMoney;
	}
	public int getBettingUserNumber() {
		return bettingUserNumber;
	}
	public void setBettingUserNumber(int bettingUserNumber) {
		this.bettingUserNumber = bettingUserNumber;
	}
	public int getWinnerNumbers() {
		return winnerNumbers;
	}
	public void setWinnerNumbers(int winnerNumbers) {
		this.winnerNumbers = winnerNumbers;
	}
	public long getSingleUserBetMoney() {
		return singleUserBetMoney;
	}
	public void setSingleUserBetMoney(long singleUserBetMoney) {
		this.singleUserBetMoney = singleUserBetMoney;
	}
	public long getSingleUserWinMoney() {
		return singleUserWinMoney;
	}
	public void setSingleUserWinMoney(long singleUserWinMoney) {
		this.singleUserWinMoney = singleUserWinMoney;
	}
	
}
